//
//  MyInstituViewUpateController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/11/6.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "MyInstituViewUpateController.h"
#import "BRTextField.h"
#import "ApplyInLicenseCell.h"
#import "ApplyInTextviewCell.h"
#import "ApplyInDetailCell.h"
#import "ApplyInIdentfierCell.h"
#import "ApplyInCompanyScaleCell.h"
#import "ApplyInforInstitution.h"
#import "AddressManagerViewController.h"
#import "GFDatePicker.h"
#import "UITextView+UITextView_LLKAdjust.h"
#import "InstituSubmiteOverView.h"
#import "OrganationITypeChooseViewController.h"
#import "InstituTypeChooseView.h"
#import "OrganationApplyStateCell.h"
#import "ApplyInstituChooseCell.h"
#import "InstituTypeShowView.h"
#import "ACEExpandableTextCell.h"
#import "ApplyInDescripTextCell.h"
#import "OrganationApplySubmitView.h"
#import "GFPeopleCountChooseView.h"
#import "DisclaimerView.h"
#import <MapKit/MapKit.h>
#import "MyNeedUpDataModel.h"
@interface MyInstituViewUpateController ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,UIActionSheetDelegate,UIImagePickerControllerDelegate,UIViewControllerTransitioningDelegate,GetBabySexInformation,GetPeopleCountInformation>
{
    NSInteger rowsNumber;
    NSInteger imageviewTag;
    CGFloat _cellHeight[2];
    CGFloat _latitude;
    CGFloat _longtitude;
    UILabel * placeholderLabel;
}



@property (nonatomic, strong) NSMutableArray *cellData;
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *titleArray;
@property(nonatomic,strong)UITextView *nameTextView;
@property(nonatomic,strong)UITextView *establelishTimeTextView;
@property(nonatomic,strong)UITextView *registerCountTextView;
@property(nonatomic,strong)UITextView *phoneNumberTextView;
@property(nonatomic,strong)UITextView *addresTextView;
@property(nonatomic,strong)UITextView *descrptionTextView;
@property(nonatomic,strong)UITextView *emailTextView;
@property(nonatomic,strong)UIImageView *currenImageView;

@property(nonatomic,strong)UIActionSheet *actionSheet;
@property(nonatomic,strong)ApplyInforInstitution *sexView;
@property(nonatomic,strong)NSMutableArray *IdsArray;
@property(nonatomic,copy)NSString *businessLicenceID;
@property(nonatomic,copy)NSString *idCardFront;
@property(nonatomic,copy)NSString *idCardOpposite;
@property(nonatomic,copy)NSString *logoId;
@property(nonatomic,copy)NSString *coverId;
@property(nonatomic,copy)NSString *addressId;
@property(nonatomic,strong)UILabel *dateLabel;
@property(nonatomic,strong)UILabel *addressLabel;
//@property(nonatomic,copy)NSString *nameStr;
//@property(nonatomic,copy)NSString *phoneNumberStr;
@property(nonatomic,strong)NSMutableArray *imagesArray;
@property(nonatomic,strong)NSMutableArray *textsArray;
@property(nonatomic,strong)NSMutableArray *imageIdsArray;
@property(nonatomic,strong)NSDictionary *atlasDic;
@property(nonatomic,strong)NSMutableArray *atlasArray;

@property(nonatomic,strong)UIImageView *chooesImageView;

@property(nonatomic,strong)MBProgressHUD *hud;
@property(nonatomic,strong)InstituTypeChooseView *shareView;
@property(nonatomic,strong)UIView *backView;
@property(nonatomic,strong)InstituTypeShowView *typeShowView;
@property(nonatomic,strong)OrganationApplySubmitView *submitView;
@property(nonatomic,strong)NSMutableArray *chooseShowArray;

@property(nonatomic,strong)UIButton *instiChooseButton;
@property(nonatomic,strong)NSMutableArray *chooseIdsArray;
@property(nonatomic,strong)UIButton *chooesBtn;
@property(nonatomic,strong)GFPeopleCountChooseView *peoleCount;
@property(nonatomic,strong)UILabel *peopleCountLabel;
@property(nonatomic,strong)DisclaimerView *disclamerview;
@property(nonatomic,strong)NSMutableArray *orginalDataArray;
@property(nonatomic,assign)BOOL gotoUpdateBefore;
@end

@implementation MyInstituViewUpateController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gotoUpdateBefore = NO;
    self.title = @"申请机构入驻";
    [self createNavagationBackBtn];
    rowsNumber = 1;
     [self getAllMyListInformation];
     [self createTableviewUI];
   
    if (self.gotoUpdateBefore) {
       
//        MyNeedUpDataModel *model = self.orginalDataArray[0];
//        rowsNumber = model.institutionImgs.count;
//        [self.tableView reloadData];
    }

    // Do any additional setup after loading the view.
}
-(void)createNavagationBackBtn{
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 6 , 22, 23);
    UIImageView *backImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navigator_btn_back"]];
    backImg.frame = CGRectMake(-10, 10, 22, 22);
    [backBtn addSubview:backImg];
    [backImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backBtn.mas_left).offset(-10);
        make.centerY.equalTo(backBtn.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(22, 22));
    }];
    [backBtn addTarget:self action:@selector(leftBarButtonItemPressed:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    [self.navigationItem setLeftBarButtonItem:leftButton];
    
}
-(void)leftBarButtonItemPressed:(UIButton *)btn{
    NSArray *viewcontrollers=self.navigationController.viewControllers;
    if (viewcontrollers.count>1) {
        if ([viewcontrollers objectAtIndex:viewcontrollers.count - 1] == self) {
            //push方式
            [self.navigationController popViewControllerAnimated:YES];
        }
    }
    else{
        //present方式
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
}
-(void)createTableviewUI{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT - 64) style:UITableViewStyleGrouped];
    [self.view addSubview:self.tableView];
    [self.tableView setSeparatorColor:COLOR_HEX(0xE8E8E8)];
    self.tableView.estimatedRowHeight = 200;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[ApplyInLicenseCell class] forCellReuseIdentifier:@"ApplyInLicenseCell"];
    [self.tableView registerClass:[ApplyInDetailCell class] forCellReuseIdentifier:@"ApplyInDetailCell"];
    [self.tableView registerClass:[ApplyInIdentfierCell class] forCellReuseIdentifier:@"ApplyInIdentfierCell"];
    [self.tableView registerClass:[ApplyInCompanyScaleCell class] forCellReuseIdentifier:@"ApplyInCompanyScaleCell"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell1"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell2"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell4"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell5"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell6"];
    [self.tableView registerClass:[ApplyInTextviewCell class] forCellReuseIdentifier:@"ApplyInTextviewCell7"];
    [self.tableView registerClass:[OrganationApplyStateCell class] forCellReuseIdentifier:@"OrganationApplyStateCell"];
    [self.tableView registerClass:[ApplyInDescripTextCell class] forCellReuseIdentifier:@"ApplyInDescripTextCell"];
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return self.titleArray.count;
    }
    return rowsNumber;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MyNeedUpDataModel *model;
    if (self.gotoUpdateBefore) {
        model = self.orginalDataArray[0];
    }
    
    if (indexPath.section == 0) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
        switch (indexPath.row) {
            case 0:
            {

                ApplyInTextviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInTextviewCell"];
                if (self.gotoUpdateBefore) {
                    self.nameTextView = [self getAtFirstTextView:cell];
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                    self.nameTextView.text = model.name;
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.nameTextView]) {
                        return cell;
                    }
                }
                self.nameTextView = [self getTextView:cell AndWithTitle:@"请输入你的名字"];
                cell.titleLabel.text = self.titleArray[indexPath.row];
                return cell;
            }
                break;
            case 1:
            {
                ApplyInTextviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInTextviewCell1"];
                if (self.gotoUpdateBefore) {
                    for (UIView *view in cell.contentView.subviews) {
                        if ([view isEqual:self.dateLabel]) {
                            [view removeFromSuperview];
                        }
                    }
                    self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(15), scaleLeftAndRight(200), scaleTopAndBottom(20))];
                    self.dateLabel.font = [UIFont systemFontOfSize:15];
                    self.dateLabel.textColor = COLOR_HEX(0x121212);
                    self.dateLabel.textAlignment = NSTextAlignmentLeft;
                    [cell.contentView addSubview:self.dateLabel];
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                self.dateLabel.text = [self timeBackAccoringValue:model.foundTime];
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.dateLabel]) {
                        return cell;
                    }
                }
                self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(15), scaleLeftAndRight(200), scaleTopAndBottom(20))];
                self.dateLabel.font = [UIFont systemFontOfSize:15];
                self.dateLabel.textColor = COLOR_HEX(0x121212);
                self.dateLabel.textAlignment = NSTextAlignmentLeft;
                [cell.contentView addSubview:self.dateLabel];
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                cell.titleLabel.text = self.titleArray[indexPath.row];
                return cell;
            }
                break;
            case 2:
            {
                ApplyInTextviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInTextviewCell2"];
                if (self.gotoUpdateBefore) {
                    self.registerCountTextView = [self getAtFirstTextView:cell];
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                     self.registerCountTextView.text = model.registerNumber;
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.registerCountTextView]) {
                        return cell;
                    }
                }
                self.registerCountTextView = [self getTextView:cell AndWithTitle:@"请输入注册号"];
                cell.titleLabel.text = self.titleArray[indexPath.row];
                return cell;
                
            }
                break;
            case 3:
            {
                ApplyInCompanyScaleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInCompanyScaleCell"];
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.peopleCountLabel]) {
                        [view removeFromSuperview];
                    }
                }
                if (self.gotoUpdateBefore) {
                    self.peopleCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(15), scaleLeftAndRight(200), scaleTopAndBottom(20))];
                    self.peopleCountLabel.font = [UIFont systemFontOfSize:15];
                    self.peopleCountLabel.textColor = COLOR_HEX(0x121212);
                    self.peopleCountLabel.textAlignment = NSTextAlignmentLeft;
                    [cell.contentView addSubview:self.peopleCountLabel];
                    cell.selectionStyle = UITableViewCellSelectionStyleNone;
                    self.peopleCountLabel.text = [self accodingDetailBackBtnChooseInfor:model.number];
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.peopleCountLabel]) {
                        return cell;
                    }
                }
                self.peopleCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(15), scaleLeftAndRight(200), scaleTopAndBottom(20))];
                self.peopleCountLabel.font = [UIFont systemFontOfSize:15];
                self.peopleCountLabel.textColor = COLOR_HEX(0x121212);
                self.peopleCountLabel.textAlignment = NSTextAlignmentLeft;
                [cell.contentView addSubview:self.peopleCountLabel];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;

                return cell;
            }
                break;
            case 4:
            {
                ApplyInTextviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInTextviewCell4"];
                if (self.gotoUpdateBefore) {
                    self.phoneNumberTextView =  [self getAtFirstTextView:cell];
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                    self.phoneNumberTextView.text = model.phoneNumber;
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.phoneNumberTextView]) {
                        return cell;
                    }
                }
                self.phoneNumberTextView = [self getTextView:cell AndWithTitle:@"请输入手机号"];
                cell.titleLabel.text = self.titleArray[indexPath.row];

                return cell;
            }
                break;
            case 5:
            {
                ApplyInTextviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInTextviewCell5"];
                if (self.gotoUpdateBefore) {
                   self.emailTextView =  [self getAtFirstTextView:cell];
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                    self.emailTextView.text = model.email;
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.emailTextView]) {
                        return cell;
                    }
                }
                self.emailTextView = [self getTextView:cell AndWithTitle:@"请输入邮箱"];
                cell.titleLabel.text = self.titleArray[indexPath.row];

                return cell;
            }
                break;
            case 6:
            {
                ApplyInTextviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInTextviewCell6"];
                for (UIView *subViews in cell.contentView.subviews) {
                    if ([subViews isEqual:self.addressLabel]) {
                        [subViews removeFromSuperview];
                    }
                }
                if (self.gotoUpdateBefore) {
                    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(15),scaleLeftAndRight(200), scaleTopAndBottom(20))];
                    self.addressLabel.font = [UIFont systemFontOfSize:15];
                    self.addressLabel.textColor = COLOR_HEX(0x121212);
                    self.addressLabel.textAlignment = NSTextAlignmentLeft;
                    [cell.contentView addSubview:self.addressLabel];
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                    self.addressLabel.text = [NSString stringWithFormat:@"%@%@%@%@",model.province,model.city,model.area,model.detailAddress];
                    return cell;
                }
                for (UIView *view in cell.contentView.subviews) {
                    if ([view isEqual:self.addressLabel]) {
                        return cell;
                    }
                }
                self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(15),scaleLeftAndRight(200), scaleTopAndBottom(20))];
                self.addressLabel.font = [UIFont systemFontOfSize:15];
                self.addressLabel.textColor = COLOR_HEX(0x121212);
                self.addressLabel.textAlignment = NSTextAlignmentLeft;
                [cell.contentView addSubview:self.addressLabel];
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                cell.titleLabel.text = self.titleArray[indexPath.row];

                return cell;
                
            }
                break;
            case 7:
            {
                ApplyInDescripTextCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInDescripTextCell"];
                for (UIView *subVies in cell.contentView.subviews) {
                    if ([subVies isEqual:self.descrptionTextView]) {
                        [subVies removeFromSuperview];
                    }
                }
                if (self.gotoUpdateBefore) {
                    self.descrptionTextView = [[UITextView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(20), scaleTopAndBottom(30), WIDTH - scaleLeftAndRight(20) * 2, scaleTopAndBottom(100))];
                    [_descrptionTextView setAutoAdjust:YES];
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                    _descrptionTextView.backgroundColor = [UIColor clearColor];
                    _descrptionTextView.font = [UIFont systemFontOfSize:16.0f];
                    _descrptionTextView.textAlignment = NSTextAlignmentLeft;
                    _descrptionTextView.delegate = self;
                    [cell.contentView addSubview:_descrptionTextView];
                    self.descrptionTextView.text = model.Descripsion;
                    return cell;
                }else{
                    self.descrptionTextView = [[UITextView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(20), scaleTopAndBottom(30), WIDTH - scaleLeftAndRight(20) * 2, scaleTopAndBottom(100))];
                    [_descrptionTextView setAutoAdjust:YES];
                    cell.titleLabel.text = self.titleArray[indexPath.row];
                    _descrptionTextView.backgroundColor = [UIColor clearColor];
                    _descrptionTextView.font = [UIFont systemFontOfSize:16.0f];
                    _descrptionTextView.textAlignment = NSTextAlignmentLeft;
                    _descrptionTextView.delegate = self;
                    [cell.contentView addSubview:_descrptionTextView];
                    return cell;
                }

            }
                break;
            case 8:
            {
                ApplyInLicenseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInLicenseCell"];
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
                [cell.pictureView addGestureRecognizer:tap];
                cell.pictureView.tag = 500;
                cell.titleLabel.text = @"营业执照";
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                if (self.gotoUpdateBefore) {
                    [cell.pictureView sd_setImageWithURL:[NSURL URLWithString:model.businessLicencePath] placeholderImage:[UIImage imageNamed:@"中"]];
                }
                return cell;
            }
                break;
            case 9:
            {
                ApplyInIdentfierCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInIdentfierCell"];
                cell.titleLabel.text = self.titleArray[indexPath.row];
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
                UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
                cell.backImageView.tag = 501;
                cell.frontImageView.tag = 502;
                [cell.backImageView addGestureRecognizer:tap];
                [cell.frontImageView addGestureRecognizer:tap1];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                if (self.gotoUpdateBefore) {
                    [cell.backImageView sd_setImageWithURL:[NSURL URLWithString:model.idCardFrontPath] placeholderImage:[UIImage imageNamed:@"小"]];
                    [cell.frontImageView sd_setImageWithURL:[NSURL URLWithString:model.idCardOppositePath] placeholderImage:[UIImage imageNamed:@"小"]];
                }
                return cell;
            }
                break;
            case 10:
            {
                self.instiChooseButton = [UIButton buttonWithType:UIButtonTypeCustom];
                self.instiChooseButton.frame = CGRectMake(WIDTH - scaleLeftAndRight(65), scaleTopAndBottom(15), scaleLeftAndRight(60), scaleTopAndBottom(20));
                [self.instiChooseButton setTitle:@"选项" forState:0];
                self.instiChooseButton.layer.cornerRadius = scaleTopAndBottom(4);
                self.instiChooseButton.layer.masksToBounds = YES;
                self.instiChooseButton.backgroundColor = [UIColor orangeColor];
                self.instiChooseButton.titleLabel.font = [UIFont systemFontOfSize:15];
                [self.instiChooseButton addTarget:self action:@selector(InstitiTypeChoose:) forControlEvents:UIControlEventTouchUpInside];
                
                if (self.chooseShowArray.count == 0) {
                    //                        self.typeShowView.dataArray = (NSMutableArray *)@[];
                    [self.instiChooseButton setTitle:@"选项" forState:0];
                }else{
                    [self.typeShowView.dataArray addObjectsFromArray:self.chooseShowArray];
                    //                        self.typeShowView.dataArray = [self.chooseShowArray mutableCopy];
                    [[NSUserDefaults standardUserDefaults] setObject:self.typeShowView.dataArray forKey:@"typeShowData"];
                    NSLog(@"这是他们这个的所有类型%@",self.typeShowView.dataArray);
                    [self.instiChooseButton setTitle:@"修改" forState:0];
                }
                ApplyInstituChooseCell *cell = [[ApplyInstituChooseCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellID"];
                self.typeShowView = [[InstituTypeShowView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(10), scaleTopAndBottom(50), WIDTH - scaleLeftAndRight(20), scaleTopAndBottom(90) * self.typeShowView.dataArray.count)];
                [cell.contentView addSubview:self.instiChooseButton];
                //                    self.typeShowView.dataArray = [self.chooseShowArray mutableCopy];
                [cell.contentView addSubview:self.typeShowView];
                [self.typeShowView.collectionView reloadData];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                return cell;
            }
                break;
            case 11:
            {
                ApplyInLicenseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInLicenseCell"];
                cell.titleLabel.text = @"LOGO";
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
                [cell.pictureView addGestureRecognizer:tap];
                cell.pictureView.tag = 503;
                if (self.gotoUpdateBefore) {
                    [cell.pictureView sd_setImageWithURL:[NSURL URLWithString:model.logoPath] placeholderImage:[UIImage imageNamed:@"中"]];
                }
                return cell;
            }
                break;
            case 12:
            {
                ApplyInLicenseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApplyInLicenseCell"];
                cell.titleLabel.text = @"封面图片";
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
                [cell.pictureView addGestureRecognizer:tap];
                cell.pictureView.tag = 504;
                if (self.gotoUpdateBefore) {
                    [cell.pictureView sd_setImageWithURL:[NSURL URLWithString:model.imgPath] placeholderImage:[UIImage imageNamed:@"中"]];
                }
                return cell;
            }
                break;
            default:
                break;
        }
        return cell;
    }else{
        
        NSString *strin = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
        [self.tableView registerClass:[ApplyInDetailCell class] forCellReuseIdentifier:strin];
        ApplyInDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:strin];
        if (self.gotoUpdateBefore) {
//            NSArray *tujiArray = model.institutionImgs;
//            if (tujiArray.count < rowsNumber) {
//                cell.pictureView.image = self.imagesArray[indexPath.row];
//                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
//                [cell.descriptextVeiw setAutoAdjust:YES];
//                cell.descriptextVeiw.delegate = self;
//                [cell.pictureView addGestureRecognizer:tap];
//                if (indexPath.row == 0) {
//                    cell.deleBtn.hidden = YES;
//                }else{
//                    cell.deleBtn.hidden = NO;
//                }
//                cell.pictureView.tag = 600 + indexPath.row;
//                cell.deleBtn.tag = 700 + indexPath.row;
//                [cell.deleBtn addTarget:self action:@selector(deleteOneTableCell:) forControlEvents:UIControlEventTouchUpInside];
//                return cell;
//            }
//            CatagoryModel *model = tujiArray[indexPath.row];
//            [cell.pictureView sd_setImageWithURL:[NSURL URLWithString:model.imgPath] placeholderImage:[UIImage imageNamed:@"大"]];
            cell.pictureView.image = self.imagesArray[indexPath.row];
            cell.descriptextVeiw.text = self.textsArray[indexPath.row];
            cell.placeHolder.hidden = YES;
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
            [cell.descriptextVeiw setAutoAdjust:YES];
            cell.descriptextVeiw.delegate = self;
            [cell.pictureView addGestureRecognizer:tap];
            if (indexPath.row == 0) {
                cell.deleBtn.hidden = YES;
            }else{
                cell.deleBtn.hidden = NO;
            }
            cell.pictureView.tag = 600 + indexPath.row;
            cell.deleBtn.tag = 700 + indexPath.row;
            [cell.deleBtn addTarget:self action:@selector(deleteOneTableCell:) forControlEvents:UIControlEventTouchUpInside];
            return cell;
        }
        cell.pictureView.image = self.imagesArray[indexPath.row];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToClicPhoto:)];
        [cell.descriptextVeiw setAutoAdjust:YES];
        cell.descriptextVeiw.delegate = self;
        [cell.pictureView addGestureRecognizer:tap];
        if (indexPath.row == 0) {
            cell.deleBtn.hidden = YES;
        }else{
            cell.deleBtn.hidden = NO;
        }
        cell.pictureView.tag = 600 + indexPath.row;
        cell.deleBtn.tag = 700 + indexPath.row;
        [cell.deleBtn addTarget:self action:@selector(deleteOneTableCell:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    
}

/**
 展示机构类型的选择页
 
 */
-(void)InstitiTypeChoose:(UIButton *)btn{
    [self showChooseTypeUI];
}

/**
 根据手势点击进入相册选择图片
 
 */
-(void)goToClicPhoto:(UITapGestureRecognizer *)tap{
    self.currenImageView = (UIImageView *)tap.view;
    imageviewTag = self.currenImageView.tag;
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
        self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"选择图像" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照", @"从相册选择",  nil];
    }else{
        self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"选择图像" delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:nil otherButtonTitles:@"从相册选择", nil];
    }
    
    self.actionSheet.tag = 10000;
    [self.actionSheet showInView:self.view];
    
}
#pragma mark - 调用相机的代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (actionSheet.tag == 10000) {
        NSUInteger sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        // 判断是否支持相机
        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            switch (buttonIndex) {
                case 0:
                    //来源:相机
                    sourceType = UIImagePickerControllerSourceTypeCamera;
                    break;
                case 1:
                    //来源:相册
                    sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                    break;
                case 2:
                    return;
            }
        }
        else {
            if (buttonIndex == 2) {
                return;
            } else {
                sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
            }
        }
        // 跳转到相机或相册页面
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = (id)self;
        imagePickerController.allowsEditing = YES;
        imagePickerController.sourceType = sourceType;
        imagePickerController.transitioningDelegate = self;
        imagePickerController.modalPresentationStyle = UIModalPresentationCustom;
        [self presentViewController:imagePickerController animated:YES completion:nil];
    }
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self dismissViewControllerAnimated:YES completion:nil];
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSLog(@"获取到的tag值%ld",(long)imageviewTag);
    if (imageviewTag >= 600) {
        [self.imagesArray replaceObjectAtIndex:imageviewTag - 600 withObject:image];
        NSLog(@"%@",self.imagesArray);
    }
    self.currenImageView.image = image;
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = PictureIp@"/file/fileUpload";
    switch (imageviewTag) {
        case 500:
        {
            [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                NSData *imageData = UIImagePNGRepresentation(image);
                [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];
            } progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                self.businessLicenceID = dict[@"id"];
                NSLog(@"获取到的数据%@",dict);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                
            }];
            
        }
            break;
        case 501:
        {
            [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                NSData *imageData = UIImagePNGRepresentation(image);
                [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];
            } progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                self.idCardOpposite = dict[@"id"];
                NSLog(@"获取到的数据%@",dict);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                
            }];
            
        }
            break;
        case 502:
        {
            [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                NSData *imageData = UIImagePNGRepresentation(image);
                [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];
            } progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                self.idCardFront = dict[@"id"];
                NSLog(@"获取到的数据%@",dict);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                
            }];
            
        }
            break;
        case 503:
        {
            [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                NSData *imageData = UIImagePNGRepresentation(image);
                [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];
            } progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                self.logoId = dict[@"id"];
                NSLog(@"获取到的数据%@",dict);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                
            }];
            
        }
            break;
        case 504:
        {
            [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                NSData *imageData = UIImagePNGRepresentation(image);
                [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];
            } progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                self.coverId = dict[@"id"];
                NSLog(@"获取到的数据%@",dict);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                
            }];
            
        }
            break;
        default:
            break;
    }
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];
    view.alpha = 1.0f;
    if (section == 1) {
        UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [addBtn setTitle:@"继续添加一项" forState:UIControlStateNormal];
        [addBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        addBtn.backgroundColor = COLOR_HEX(0xFFC921);
        [addBtn addTarget:self action:@selector(addOneTableCell:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:addBtn];
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor lightGrayColor];
        [view addSubview:lineView];
        [addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(20));
            make.top.equalTo(view.mas_top).offset(scaleTopAndBottom(10));
            make.right.equalTo(view.mas_right).offset(scaleLeftAndRight(-20));
            make.height.mas_equalTo(scaleTopAndBottom(35));
        }];
        addBtn.layer.cornerRadius = scaleTopAndBottom(5);
        addBtn.layer.masksToBounds = YES;
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(view);
            make.top.equalTo(addBtn.mas_bottom).offset(scaleTopAndBottom(10));
            make.height.mas_equalTo(0.5f);
        }];
        [self createInView:view AndAboveView:lineView];
    }
    return view;
}
-(void)createInView:(UIView *)view AndAboveView:(UIView *)aboveView{
    
    self.chooesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.chooesBtn setBackgroundImage:[UIImage imageNamed:@"圆角矩形-3"] forState:UIControlStateNormal];
    [self.chooesBtn setBackgroundImage:[UIImage imageNamed:@"对号-(3)"] forState:UIControlStateSelected];
    [self.chooesBtn addTarget:self action:@selector(chooseOrNotChoose:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:_chooesBtn];
    [_chooesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(15));
        make.top.equalTo(aboveView.mas_bottom).offset(scaleTopAndBottom(20));
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    UILabel *readLabel = [[UILabel alloc] init];
    [view addSubview:readLabel];
    readLabel.text = @"我已阅读并同意,";
    readLabel.font = [UIFont systemFontOfSize:13];
    //    readLabel.adjustsFontSizeToFitWidth = YES;
    readLabel.textAlignment = NSTextAlignmentCenter;
    [readLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_chooesBtn.mas_right).offset(scaleLeftAndRight(0));
        make.top.equalTo(aboveView.mas_bottom).offset(scaleTopAndBottom(20));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(120), scaleTopAndBottom(15)));
    }];
    UIButton *introdBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [introdBtn setTitleColor:COLOR_HEX(0xF9D025) forState:UIControlStateNormal];
    introdBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    //    introdBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
    [introdBtn setTitle:@"免责声明" forState:UIControlStateNormal];
    [introdBtn addTarget:self action:@selector(showDiscalView:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:introdBtn];
    [introdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(readLabel.mas_right).offset(scaleLeftAndRight(0));
        make.top.equalTo(aboveView.mas_bottom).offset(scaleTopAndBottom(20));
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(80), scaleTopAndBottom(15)));
    }];
    UIButton *commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    commitBtn.backgroundColor = COLOR_HEX(0xF9D025);
    [commitBtn setTitle:@"提交资料" forState:UIControlStateNormal];
    commitBtn.layer.cornerRadius = scaleTopAndBottom(20);
    commitBtn.layer.masksToBounds = YES;
    [commitBtn addTarget:self action:@selector(submitInstitutionInformation) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:commitBtn];
    [commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(15));
        make.top.equalTo(readLabel.mas_bottom).offset(scaleTopAndBottom(20));
        make.right.equalTo(view.mas_right).offset(scaleLeftAndRight(-15));
        make.height.mas_equalTo(scaleTopAndBottom(40));
    }];
}
-(void)chooseOrNotChoose:(UIButton *)btn{
    btn.selected = !btn.selected;
    
    NSLog(@"同意或不同意");
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 1) {
        return scaleTopAndBottom(150);
    }
    return 0.01f;
}
-(void)addOneTableCell:(UIButton *)btn{
    rowsNumber++;
    UIImage *image = [UIImage imageNamed:@"大"];
    [self.imagesArray addObject:image];
    [self.textsArray addObject:@" "];
    NSLog(@"%@",self.imagesArray);
    [self.tableView beginUpdates];
    NSIndexPath *index = [NSIndexPath indexPathForRow:rowsNumber - 1 inSection:1];
    ApplyInDetailCell *cell = [self.tableView cellForRowAtIndexPath:index];
    cell.pictureView.image = [UIImage imageNamed:@""];
    [self.tableView insertRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView endUpdates];
    
}
-(void)deleteOneTableCell:(UIButton *)btn{
    rowsNumber--;
    NSLog(@"%ld=%ld",(long)rowsNumber,btn.tag - 700);
    if (rowsNumber >= btn.tag - 700) {
        NSIndexPath *index = [NSIndexPath indexPathForRow:btn.tag - 700 inSection:1];
        [self.tableView beginUpdates];
        [self.tableView deleteRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
        [self.tableView endUpdates];
        [self.imagesArray removeObjectAtIndex:btn.tag - 700];
        [self.textsArray removeObjectAtIndex:btn.tag - 700];
        NSLog(@"%@",self.imagesArray);
    }else{
        NSIndexPath *index = [NSIndexPath indexPathForRow:rowsNumber inSection:1];
        [self.tableView beginUpdates];
        [self.tableView deleteRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];
        [self.tableView endUpdates];
        [self.imagesArray removeObjectAtIndex:rowsNumber];
        [self.textsArray removeObjectAtIndex:rowsNumber];
        NSLog(@"%@",self.imagesArray);
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        switch (indexPath.row) {
            case 0:
            case 1:
            case 2:
            case 4:
            case 5:
            case 6:
            {
                return scaleTopAndBottom(50);
            }
                break;
                
            case 3:
            {
                return scaleTopAndBottom(50);
            }
                break;
            case 7:
            {
                return scaleTopAndBottom(150);
            }
                break;
            case 8:
            case 11:
            case 12:
            {
                return scaleTopAndBottom(100);
            }
                break;
            case 9:
            {
                return scaleTopAndBottom(100);
            }
                break;
            case 10:
            {
                if (self.chooseShowArray.count == 0) {
                    return scaleTopAndBottom(50);
                }
                return scaleTopAndBottom(50) + scaleTopAndBottom(90) * self.chooseShowArray.count;
            }
            default:
                break;
        }
    }else if (indexPath.section == 1){
        return scaleTopAndBottom(350);
    }
    return scaleTopAndBottom(170);
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return scaleTopAndBottom(44);
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];
    if (section == 0) {
        return [self createHeaderViewAboutUI:@"机构信息" AndAddSubviewToFatherview:view];
    }
    return [self createHeaderViewAboutUI:@"机构详情" AndAddSubviewToFatherview:view];
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        //分割线补全
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
    }else{
        //分割线补全
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsMake(0, WIDTH, 0, 0)];
        }
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
            [cell setSeparatorInset:UIEdgeInsetsMake(0, WIDTH, 0, 0)];
        }
    }
    
}
//创建tableview的头部视图
-(UIView *)createHeaderViewAboutUI:(NSString *)headerTitle AndAddSubviewToFatherview:(UIView *)fatherView{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = COLOR_HEX(0xffc91f);
    [fatherView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(fatherView.mas_centerY);
        make.left.equalTo(fatherView.mas_left).offset(scaleLeftAndRight(10));
        make.height.mas_equalTo(scaleTopAndBottom(13));
        make.width.mas_equalTo(scaleLeftAndRight(2));
    }];
    UILabel *lable = [[UILabel alloc] init];
    lable.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
    lable.font = [UIFont systemFontOfSize:15];
    lable.textColor = COLOR_HEX(0x121212);
    
    [fatherView addSubview:lable];
    lable.text = headerTitle;
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view.mas_right).offset(scaleLeftAndRight(7));
        make.top.equalTo(fatherView.mas_top);
        make.bottom.equalTo(fatherView.mas_bottom);
        make.right.equalTo(fatherView.mas_right).offset(scaleLeftAndRight(-10));
    }];
    return fatherView;
}

/**
 根据选中状态选择页面
 */
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    MyNeedUpDataModel *models = self.orginalDataArray[0];
    if (indexPath.section == 0) {
        if (indexPath.row == 10) {
            
            
            
        }
        if (indexPath.row == 3) {
            self.peoleCount = [[GFPeopleCountChooseView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
            self.peoleCount.delegate = self;
            [self.view addSubview:self.peoleCount];
        }
        if (indexPath.row == 6) {
            AddressManagerViewController *addressvc = [[AddressManagerViewController alloc] init];
            addressvc.addressBlock = ^(AddressModel *model) {
                self.addressId = model.Id;
                self.addressLabel.text = [NSString stringWithFormat:@"%@%@%@%@",model.province,model.city,model.area,model.address];
                models.province = model.province;
                models.city = model.city;
                models.area = model.area;
                models.detailAddress = model.address;
                [self ForwardCode:self.addressLabel.text];
            };
            [self.navigationController pushViewController:addressvc animated:YES];
        }
        if (indexPath.row == 1) {
            __weak typeof(self) weakSelf = self;
            [GFDatePicker showCustomDatePickerAtView:self.view choosedDateBlock:^(NSDate *date) {
                NSString *dateStr = [NSString stringWithFormat:@"%@",date];
                self.dateLabel.text = [dateStr componentsSeparatedByString:@" "][0];
                models.foundTime = [NSString stringWithFormat:@"%ld",[weakSelf timeSwitchTimestamp:self.dateLabel.text andFormatter:@"YYYY-MM-dd"]];
//                model.foundTime = [dateStr componentsSeparatedByString:@" "][0];
            } cancelBlock:^{
                
            }];
        }
    }
}
-(void)showChooseTypeUI{
    self.backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    _backView.alpha = 0.5f;
    _backView.backgroundColor = [UIColor blackColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removessbackView:)];
    [_backView addGestureRecognizer:tap];
    [[UIApplication sharedApplication].keyWindow addSubview:_backView];
    _shareView = [[InstituTypeChooseView alloc] initWithFrame:CGRectMake(10, HEIGHT, WIDTH - 20, HEIGHT - 30)];
    __weak typeof(self) weakself = self;
    _shareView.closeViewBlock = ^{
        __strong typeof(self) strongself = weakself;
        [strongself.backView removeFromSuperview];
        NSLog(@"璇去到的%@",strongself.shareView.chooseDataArray);
        NSArray *array = [strongself backNewArray:strongself.shareView.chooseDataArray];
        NSLog(@"传递过来的所有key%@",array);
        strongself.chooseShowArray = [strongself bckeAllChooseDateWithNewArray:array];
        
        NSLog(@"你要的键值对%@",strongself.shareView.vlauesAndIdsArray);
        for (NSInteger i = 0; i < strongself.shareView.vlauesAndIdsArray.count; i++) {
            NSDictionary *dict = strongself.shareView.vlauesAndIdsArray[i];
            NSLog(@"小字典%@",dict);
            NSLog(@"选去过啦%@",strongself.chooseShowArray);
            NSLog(@"哈哈哈哈%@",[dict allValues][0]);
            for (NSInteger j = 0; j < strongself.shareView.chooseDataArray.count; j++) {
                NSDictionary *vlaueDic = strongself.shareView.chooseDataArray[j];
                NSString *valueee = [vlaueDic allValues][0];
                if ([valueee isEqual:[dict allValues][0]]) {
                    [strongself.chooseIdsArray addObject:[dict allKeys][0]];
                }
            }
        }
        NSIndexPath *index = [NSIndexPath indexPathForRow:10 inSection:0];
        [strongself.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationRight];
        NSLog(@"所有信息%@",strongself.chooseShowArray);
        NSLog(@"所有的ID信息%@",strongself.chooseIdsArray);
    };
    [[UIApplication sharedApplication].keyWindow addSubview:_shareView];
    [UIView animateWithDuration:0.1 animations:^{
        _shareView.frame = CGRectMake(10, HEIGHT - (HEIGHT - 30), WIDTH - 20, HEIGHT - 30);
    }];
}
-(NSArray *)backNewArray:(NSMutableArray *)arra{
    NSMutableArray *keysArra = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < arra.count; i++) {
        NSDictionary *dic = arra[i];
        [keysArra addObject:[dic allKeys][0]];
    }
    NSSet *set = [NSSet setWithArray:keysArra];
    return   [set allObjects];
}
-(NSMutableArray *)bckeAllChooseDateWithNewArray:(NSArray *)arr{
    NSMutableArray *backArray = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < arr.count; i++) {
        NSString *key = arr[i];
        NSMutableDictionary *dictt = [[NSMutableDictionary alloc] init];
        NSMutableArray *arra = [[NSMutableArray alloc] init];
        
        for (NSInteger j = 0; j < self.shareView.chooseDataArray.count; j++) {
            NSDictionary *dic = self.shareView.chooseDataArray[j];
            NSLog(@"哲哲字典%@",dic);
            if ([[dic allKeys][0] isEqual:key]) {
                [arra addObject:[dic allValues][0]];
            }
            
        }
        NSLog(@"这哲哲%@",arra);
        [dictt setObject:arra forKey:key];
        [backArray addObject:dictt];
    }
    return backArray;
}
-(void)sendAllDataValue:(UIButton *)btn{
    NSLog(@"获取到的所有数据%@",_shareView.chooseDataArray);
    [UIView animateWithDuration:0.1 animations:^{
        [_backView removeFromSuperview];
        [_shareView removeFromSuperview];
    }];
    
}
-(void)removessbackView:(UITapGestureRecognizer *)tap{
    [UIView animateWithDuration:0.1 animations:^{
        UIView *view = tap.view;
        [view removeFromSuperview];
        [_shareView removeFromSuperview];
    }];
}

#pragma mark -性别的代理方法
-(void)getBabySexInformation:(NSString *)sex{
    [self.sexView removeFromSuperview];
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:10 inSection:0];
    UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexpath];
    cell.detailTextLabel.text = sex;
}
-(void)GFBabySexPickerCancleAction{
    [self.sexView removeFromSuperview];
}
#pragma mark -人数的代理方法
-(void)getPeopleInformation:(NSString *)count{
    [self.peoleCount removeFromSuperview];
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:3 inSection:0];
    self.peopleCountLabel.text = count;
    MyNeedUpDataModel *models = self.orginalDataArray[0];
    models.number = [self accodingBtnChooseBackInfor:self.peopleCountLabel.text];
    NSLog(@"人数选择%@",count);
}
-(void)GFPeoplePickerCancleAction{
    [self.peoleCount removeFromSuperview];
}
-(NSArray *)titleArray{
    if (_titleArray == nil) {
        _titleArray = @[@"名称",@"成立时间",@"企业注册号",@"企业规模（人）",@"联系电话",@"邮箱地址",@"机构地址",@"描述/介绍",@"营业执照",@"手持身份证",@"所有机构类型",@"LOGO",@"封面图片"];
    }
    return _titleArray;
}
-(NSMutableArray *)IdsArray{
    if (_IdsArray == nil) {
        _IdsArray = [[NSMutableArray alloc] init];
    }
    return _IdsArray;
}
/**
 创建首先进入的textview
 */
- (UITextView *)getAtFirstTextView:(ApplyInTextviewCell *)cell{
    UITextView * textView = [[UITextView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(5), scaleLeftAndRight(200), scaleTopAndBottom(40))];
    [textView setAutoAdjust:YES];
//    UILabel * placeholderLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, -5, scaleTopAndBottom(120), 44)];
//    placeholderLabel.tag = 1000010;
//    placeholderLabel.text = placeTitle;
//    placeholderLabel.textColor = COLOR_HEX(0xC0C0C0);
//    placeholderLabel.font = [UIFont systemFontOfSize:15];
//    [textView addSubview:placeholderLabel];
    //    textView.backgroundColor = [UIColor clearColor];
    textView.font = [UIFont systemFontOfSize:16.0f];
    textView.textAlignment = NSTextAlignmentLeft;
    textView.delegate = self;
    [cell.contentView addSubview:textView];
    //    [textView mas_updateConstraints:^(MASConstraintMaker *make) {
    //        make.centerY.equalTo(cell.contentView.mas_centerY);
    //    }];
    return textView;
}
/**
 创建textview
 */
- (UITextView *)getTextView:(ApplyInTextviewCell *)cell AndWithTitle:(NSString *)placeTitle{
    UITextView * textView = [[UITextView alloc] initWithFrame:CGRectMake(scaleLeftAndRight(130), scaleTopAndBottom(5), scaleLeftAndRight(200), scaleTopAndBottom(40))];
    [textView setAutoAdjust:YES];
    UILabel * placeholderLabel = [[UILabel alloc] initWithFrame:CGRectMake(2, -5, scaleTopAndBottom(120), 44)];
    placeholderLabel.tag = 1000010;
    placeholderLabel.text = placeTitle;
    placeholderLabel.textColor = COLOR_HEX(0xC0C0C0);
    placeholderLabel.font = [UIFont systemFontOfSize:15];
    [textView addSubview:placeholderLabel];
    //    textView.backgroundColor = [UIColor clearColor];
    textView.font = [UIFont systemFontOfSize:16.0f];
    textView.textAlignment = NSTextAlignmentLeft;
    textView.delegate = self;
    [cell.contentView addSubview:textView];
    //    [textView mas_updateConstraints:^(MASConstraintMaker *make) {
    //        make.centerY.equalTo(cell.contentView.mas_centerY);
    //    }];
    return textView;
}
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    ApplyInDetailCell *cell  = (ApplyInDetailCell *)[[textView superview] superview];
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    NSLog(@"这是第%ld组%ld行",(long)indexPath.section,(long)indexPath.row);
    if (indexPath.section == 1) {
        [cell.descriptextVeiw setAutoAdjust:YES];
    }
    return YES;
}
-(void)textViewDidChange:(UITextView *)textView{
    ApplyInDetailCell *cell  = (ApplyInDetailCell *)[[textView superview] superview];
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    NSLog(@"这是第%ld组%ld行",(long)indexPath.section,(long)indexPath.row);
    if (indexPath.section == 1) {
        cell.placeHolder.hidden = YES;
        
        //允许提交按钮点击操作
        cell.placeHolder.hidden = YES;
        //实时显示字数
        NSLog(@"点击了");
        cell.stirngLenghLabel.text = [NSString stringWithFormat:@"%lu/255", (unsigned long)textView.text.length];
        
        //字数限制操作
        
        if (textView.text.length >= 255) {
            
            textView.text = [textView.text substringToIndex:255];
            
            cell.stirngLenghLabel.text = @"255/255";
            
        }
        
        //取消按钮点击权限，并显示提示文字
        
        if (textView.text.length == 0) {
            
            cell.placeHolder.hidden = NO;
            
        }
    }else{
        
        if (textView.text.length == 0) {
            UILabel *label = [textView viewWithTag:1000010];
            label.hidden = NO;
        } else {
            NSLog(@"就这样吧");
            UILabel *label = [textView viewWithTag:1000010];
            label.hidden = YES;
        }
        
    }
    
}
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"]){ //判断输入的字是否是回车，即按下return
        //在这里做你响应return键的代码
        [textView resignFirstResponder];
        return NO; //这里返回NO，就代表return键值失效，即页面上按下return，不会出现换行，如果为yes，则输入页面会换行
    }else{
        return YES;
    }
}

-(void)textViewDidEndEditing:(UITextView *)textView{
    if (self.gotoUpdateBefore) {
        ApplyInDetailCell *cell  = (ApplyInDetailCell *)[[textView superview] superview];
        NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
        NSLog(@"这是第%ld组%ld行",(long)indexPath.section,(long)indexPath.row);
        if (indexPath.section == 1) {
            [self.textsArray replaceObjectAtIndex:indexPath.row withObject:textView.text];
        }
    }
    if ([textView isEqual:self.descrptionTextView]) {
        MyNeedUpDataModel *model = self.orginalDataArray[0];
        model.Descripsion = textView.text;
    }
//    ApplyInDetailCell *cell  = (ApplyInDetailCell *)[[textView superview] superview];
//    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
//    NSLog(@"这是第%ld组%ld行",(long)indexPath.section,(long)indexPath.row);
//    if (indexPath.section == 1) {
//        [self.textsArray replaceObjectAtIndex:indexPath.row withObject:textView.text];
//    }
    
}

/**
 提交机构信息
 */
-(void)submitInstitutionInformation{
    _hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    _hud.label.text = NSLocalizedString(@"Loading...", @"疯狂的加载中...");
    [self getAllImagesAndGetImagesId];
//    [self getAllAlatasArray];
}


/**
 获取到图文详情中的所有图片
 */
-(void)getAllImagesAndGetImagesId{
    dispatch_group_t group = dispatch_group_create();
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = PictureIp@"/file/fileUpload";
    for (UIImage *image in self.imagesArray) {
        dispatch_group_async(group, queue, ^{
            NSData *imageData = UIImagePNGRepresentation(image);
            [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
                if (imageData != nil) {
                    [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];// 图片数据不为空才传递
                }
                
            } progress:^(NSProgress * _Nonnull uploadProgress) {
                NSLog(@"当前线程%@",[NSThread currentThread]);
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                [self.imageIdsArray addObject:dict[@"id"]];
                NSLog(@"获取到的数据%@",dict);
                dispatch_semaphore_signal(semaphore);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                dispatch_semaphore_signal(semaphore);
            }];
            
        });
        
    }
    dispatch_group_notify(group, queue, ^{
        for (NSInteger i = 0; i < rowsNumber; i++) {
            dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        }
        [self getAccodringInstitutionAtlas];
        NSLog(@"获取到的数组ids:%@",self.imageIdsArray);
    });
}

/**
 根据机构详情的图片获取图集项
 */
-(void)getAccodringInstitutionAtlas{
    dispatch_group_t group = dispatch_group_create();
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    
    dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
    
    NSString *sessionId = [[NSUserDefaults standardUserDefaults] objectForKey:@"sessionId"];
    NSLog(@"文字数组的值%@",self.textsArray);
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = ServerIp@"/institutionApp/saveInstitutionImg";
    for (NSInteger i = 0; i < self.imageIdsArray.count; i++) {
        dispatch_group_async(group, queue, ^{
            NSString *Imgid = self.imageIdsArray[i];
            NSString *text = self.textsArray[i];
            NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:sessionId,@"sessionId",text,@"text",Imgid,@"img.id",[NSString stringWithFormat:@"%ld",(long)i],@"sort", nil];
            
            NSLog(@"字典信息的值%@",param);
            [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                [self.atlasArray addObject:jsonDic[@"id"]];
                dispatch_semaphore_signal(semaphore);
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                dispatch_semaphore_signal(semaphore);
            }];
        });
        
    }
    dispatch_group_notify(group, queue, ^{
        for (NSInteger i = 0; i < self.imageIdsArray.count; i++) {
            dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self getAllAlatasArray];
        });
        
    });
    
}

/**
 完整信息的提交审核
 */
-(void)getAllAlatasArray{
    self.chooesBtn.selected = YES;
    NSLog(@"地理信息%@",self.addressLabel.text);
    NSString *sessionId = [[NSUserDefaults standardUserDefaults] objectForKey:@"sessionId"];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = ServerIp@"/institutionApp/saveOrUpdateInstitution";
    NSInteger timeStamp = [self timeSwitchTimestamp:self.dateLabel.text andFormatter:@"yyyy-MM-dd"];
    NSString *timeStr = [NSString stringWithFormat:@"%ld",(long)timeStamp];
    NSIndexPath *index = [NSIndexPath indexPathForRow:3 inSection:0];
    //    ApplyInCompanyScaleCell *cell = [self.tableView cellForRowAtIndexPath:index];
    NSString *peoleNumber = [self accodingBtnChooseBackInfor:self.peopleCountLabel.text];
    NSLog(@"%@",peoleNumber);
    NSString *longtitude = [NSString stringWithFormat:@"%f",_longtitude];
    NSString *latitude = [NSString stringWithFormat:@"%f",_latitude];
    NSString *altasArra = [self.atlasArray componentsJoinedByString:@","];
    NSString *chooseIdsStr = [self.chooseIdsArray componentsJoinedByString:@","];
    NSLog(@"这是图集ID%@",altasArra);
    NSLog(@"这是类型IDs%@",chooseIdsStr);
    NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:self.nameTextView.text,@"name",timeStr,@"foundDate",self.emailTextView.text,@"email",self.registerCountTextView.text,@"registerNumber",self.phoneNumberTextView.text,@"phoneNumber",self.addressId,@"address.id",self.businessLicenceID,@"businessLicence.id",self.idCardOpposite,@"idCardOpposite.id",self.idCardFront,@"idCardFront.id",self.logoId,@"logo.id",sessionId,@"sessionId",self.coverId,@"img.id",self.descrptionTextView.text,@"description",altasArra,@"imgs2",peoleNumber,@"number", chooseIdsStr,@"categorys2",longtitude,@"lng",latitude,@"lat",self.needUpdateInsituId,@"id",nil];
    
    //    NSDictionary *param1 = @{@"name":self.nameTextView.text,@"foundDate":timeStr,@"registerNumber":self.registerCountTextView.text,@"number":@"1",@"phoneNumber":self.phoneNumberTextView.text,@"email":self.emailTextView.text,@"address.id":self.addressId,@"businessLicence.id":self.businessLicenceID,@"idCardFront.id":self.idCardFront,@"idCardOpposite.id":self.idCardOpposite,@"logo.id":self.logoId,@"sessionId":sessionId,@"img.id":self.coverId,@"description":@"helloword",@"id":@"6",@"imgs":self.atlasArray};
    NSLog(@"请求参数%@",param);
    [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"字典信息%@",jsonDic);
        NSLog(@"输出的信息%@",jsonDic[@"msg"]);
        dispatch_async(dispatch_get_main_queue(), ^{
            [_hud hideAnimated:YES];
            if ([jsonDic[@"msg"] integerValue] == 0) {
                [self showRewardView];
            }
            
        });
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"错误信息%@",error);
    }];
    
}
-(void)showRewardView{
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.alpha = 0.5f;
    backView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:backView];
    _submitView = [[OrganationApplySubmitView alloc] initWithFrame:CGRectZero];
    _submitView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_submitView];
    [_submitView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(0, 0));
    }];
    __weak typeof(self) weakSelf = self;
    _submitView.closeBlock = ^{
        [backView removeFromSuperview];
        [weakSelf.submitView removeFromSuperview];
    };
    [UIView animateWithDuration:1.0f animations:^{
        [_submitView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(263), scaleTopAndBottom(263)));
        }];
        
    }];
}

#pragma mark - 将某个时间转化成 时间戳

-(NSInteger)timeSwitchTimestamp:(NSString *)formatTime andFormatter:(NSString *)format{
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:format]; //(@"YYYY-MM-dd hh:mm:ss") ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    
    NSDate* date = [formatter dateFromString:formatTime]; //------------将字符串按formatter转成nsdate
    
    //时间转时间戳的方法:
    
    NSInteger timeSp = [[NSNumber numberWithDouble:[date timeIntervalSince1970]] integerValue] * 1000;
    
    NSLog(@"将某个时间转化成 时间戳&&&&&&&timeSp:%ld",(long)timeSp); //时间戳的值
    
    return timeSp;
    
}


/**
 根据按钮上边的人数返回具体的值
 
 */
-(NSString *)accodingBtnChooseBackInfor:(NSString *)peopleCount{
    
    if ([peopleCount isEqual:@"100人以下"]) {
        return [NSString stringWithFormat:@"0"];
    }else if ([peopleCount isEqual:@"100-500人"]){
        return [NSString stringWithFormat:@"1"];
    }else if ([peopleCount isEqual:@"500-1000人"]){
        return [NSString stringWithFormat:@"2"];
    }else if ([peopleCount isEqual:@"1000-5000人"]){
        return [NSString stringWithFormat:@"3"];
    }else if ([peopleCount isEqual:@"5000-10000人"]){
        return [NSString stringWithFormat:@"4"];
    }else{
        return [NSString stringWithFormat:@"5"];
    }
    
}
/**
 根据具体的值返回按钮上边的人数
 
 */
-(NSString *)accodingDetailBackBtnChooseInfor:(NSString *)peopleCount{
    
    if ([peopleCount isEqual:@"0"]) {
        return [NSString stringWithFormat:@"100人以下"];
    }else if ([peopleCount isEqual:@"1"]){
        return [NSString stringWithFormat:@"100-500人"];
    }else if ([peopleCount isEqual:@"2"]){
        return [NSString stringWithFormat:@"500-1000人"];
    }else if ([peopleCount isEqual:@"3"]){
        return [NSString stringWithFormat:@"1000-5000人"];
    }else if ([peopleCount isEqual:@"4"]){
        return [NSString stringWithFormat:@"5000-10000人"];
    }else{
        return [NSString stringWithFormat:@"10000人以上"];
    }
    
}
-(NSMutableArray *)imagesArray{
    if (_imagesArray == nil) {
        MyNeedUpDataModel *model = self.orginalDataArray[0];
        _imagesArray = [[NSMutableArray alloc] init];
        NSArray *cataArray = model.institutionImgs;
            for (NSInteger i = 0; i < cataArray.count; i++) {
                CatagoryModel *model = cataArray[i];
                UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:model.imgPath]]];
                [_imagesArray addObject:image];
            }
    }
    return _imagesArray;
}

-(NSMutableArray *)textsArray{
    if (_textsArray == nil) {
        MyNeedUpDataModel *model = self.orginalDataArray[0];
        _textsArray = [[NSMutableArray alloc] init];
        NSArray *cataArray = model.institutionImgs;
        for (NSInteger i = 0; i < cataArray.count; i++) {
            CatagoryModel *models = cataArray[i];
            [_textsArray addObject:models.text];
        }
    }
    return _textsArray;
}
-(NSMutableArray *)imageIdsArray{
    if (_imageIdsArray == nil) {
        _imageIdsArray = [[NSMutableArray alloc] init];
    }
    return _imageIdsArray;
}
-(NSMutableArray *)atlasArray{
    if (_atlasArray == nil) {
        _atlasArray = [[NSMutableArray alloc] init];
    }
    return _atlasArray;
}
-(NSMutableArray *)chooseShowArray{
    if (_chooseShowArray == nil) {
        _chooseShowArray = [[NSMutableArray alloc] init];
    }
    return _chooseShowArray;
}
//正向地理编码
-(void)ForwardCode:(NSString *)str{
    //编码对象
    CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
    //正向地理编码
    [geoCoder geocodeAddressString:str completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
        if (placemarks.count == 0) {
            NSLog(@"编码失败");
            return ;
        }
        CLPlacemark *placeMark = [placemarks lastObject];
        NSLog(@"%lf--%lf",placeMark.location.coordinate.latitude,placeMark.location.coordinate.longitude);
        _latitude = placeMark.location.coordinate.latitude;
        _longtitude = placeMark.location.coordinate.longitude;
        //根据用户位置设置地图的中心点
        //设置显示范围
        //        MKCoordinateRegion region;
        //        region.span.latitudeDelta = 0.01;
        //        region.span.longitudeDelta = 0.01;
        //        region.center = placeMark.location.coordinate;
        
    }];
    
}

/**
 免责声明
 
 */
-(void)showDiscalView:(UIButton *)btn{
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.alpha = 0.5f;
    backView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:backView];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removebackView:)];
    [backView addGestureRecognizer:tap];
    self.disclamerview = [[DisclaimerView alloc] initWithFrame:CGRectZero];
    self.disclamerview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.disclamerview];
    [self.disclamerview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(0, 0));
    }];
    [UIView animateWithDuration:1.0f animations:^{
        [self.disclamerview mas_updateConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(350), scaleTopAndBottom(500)));
        }];
        
    }];
}
-(void)removebackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
        UIView *view = tap.view;
        [view removeFromSuperview];
        [_disclamerview removeFromSuperview];
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSMutableArray *)cellData{
    if (_cellData == nil) {
        _cellData = [NSMutableArray arrayWithArray:@[@""]];
    }
    return _cellData;
}
-(NSMutableArray *)chooseIdsArray{
    if (_chooseIdsArray == nil) {
        _chooseIdsArray = [[NSMutableArray alloc] init];
    }
    return _chooseIdsArray;
}
-(NSMutableArray *)orginalDataArray{
    if (_orginalDataArray == nil) {
        _orginalDataArray = [[NSMutableArray alloc] init];
    }
    return _orginalDataArray;
}
/**
 获取我的机构的所有信息
 */
-(void)getAllMyListInformation{
    AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];
    manger.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:self.needUpdateInsituId,@"id", nil];
    NSString *url = ServerIp@"/institutionApp/institutionDetailAll";
    [manger POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *instituDic = jsonDic[@"institution"];
        MyNeedUpDataModel *model = [MyNeedUpDataModel modelWithDictionary:instituDic];
        [self.orginalDataArray addObject:model];
        MyNeedUpDataModel *models = self.orginalDataArray[0];
        rowsNumber = models.institutionImgs.count;
        self.idCardOpposite = model.idCardOppositeId;
        self.idCardFront = model.idCardFrontId;
        self.businessLicenceID = model.businessLicenceId;
        self.logoId = model.logoId;
        self.coverId = model.imgId;
        self.addressId = model.addressId;
        [self ForwardCode:[NSString stringWithFormat:@"%@%@%@%@",models.province,models.city,models.area,models.detailAddress]];
        for (NSInteger i = 0; i < model.institutionCategorys.count; i++) {
            CatagoryModel *cataModel = model.institutionCategorys[i];
            [self.chooseIdsArray addObject:cataModel.Id];
        }
        NSLog(@"选取的所有%@",self.chooseIdsArray);
        NSLog(@"选取的所有%@",self.logoId);
        self.gotoUpdateBefore = YES;
        [self.tableView reloadData];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}
/**
 时间戳转时间
 
 */
-(NSString *)timeBackAccoringValue:(NSString *)timestap{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd"];
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
    [formatter setTimeZone:timeZone];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[timestap integerValue]/1000];//现在时间,你可以输出来看下是什么格式
    NSLog(@"这是现%@",confromTimesp);
    NSString *nowtimeStr = [formatter stringFromDate:confromTimesp];
    NSLog(@"这是现在的时间吗%@",nowtimeStr);
    return nowtimeStr;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
